﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Windows;

namespace Bigeagle.WPF.Controls
{
    #region 地图标记类

    /// <summary>
    /// 地图标记类
    /// </summary>
    public class MapMarker
    {
        /// <summary>
        /// 经纬度坐标
        /// </summary>
        /// <remarks>纬度，经度</remarks>
        private string _GeoCode;

        /// <summary>
        /// 设置或获得经纬度坐标
        /// </summary>
        /// <remarks>格式为(纬度，经度)</remarks>
        [Category("地图"), Description("标记的经纬度坐标，格式为(纬度，经度)。")]
        public string GeoCode
        {
            get { return _GeoCode; }
            set { _GeoCode = value; }
        }



        /// <summary>
        /// 标记字符
        /// </summary>
        private char _Marker = 'a';

        /// <summary>
        /// 标记字符
        /// </summary>
        /// <remarks>a-Z, 0-9</remarks>
        [Category("地图"), Description("标记字符，a-Z, 0-9。")]
        public char Marker
        {
            get { return _Marker; }
            set { _Marker = value; }
        }

        /// <summary>
        /// 标记大小
        /// </summary>
        private MarkerSize _Size = MarkerSize.Mid;

        /// <summary>
        /// 设置或获得标记大小
        /// </summary>
        [Category("地图"), Description("标记的颜色，分别为tiny,mid和small")]
        public MarkerSize Size
        {
            get { return _Size; }
            set { _Size = value; }
        }

        /// <summary>
        /// 标记颜色
        /// </summary>
        private MarkerColor _Color = MarkerColor.Red;

        /// <summary>
        /// 设置或获得标记颜色
        /// </summary>
        [Category("地图"), Description("标记的颜色。")]
        public MarkerColor Color
        {
            get { return _Color; }
            set { _Color = value; }
        }


        /// <summary>
        /// 用户数据
        /// </summary>
        private object _Tag;

        /// <summary>
        /// 设置或获得用户数据
        /// </summary>
        [Browsable(false)]
        public object Tag
        {
            get { return _Tag; }
            set { _Tag = value; }
        }

        /// <summary>
        /// 用户自定义显示
        /// </summary>
        private UIElement _UserDrawingElement;

        /// <summary>
        /// 用户自定义显示
        /// </summary>
        [Category("显示") , DisplayName("自定义显示元素")] 
        public UIElement UserDrawingElement
        {
            get { return _UserDrawingElement; }
            set { _UserDrawingElement = value; }
        }



        /// <summary>
        /// 提示文本
        /// </summary>
        private string _ToolTipText = string.Empty;

        /// <summary>
        /// 设置或获得标记提示文本
        /// </summary>
        [Category("地图"), Description("标记的提示文本。")]
        public string ToolTipText
        {
            get { return _ToolTipText; }
            set { _ToolTipText = value; }
        }

        /// <summary>
        /// 地图标记的zindex
        /// </summary>
        private int _ZIndex = 50;

        /// <summary>
        /// 设置或获得地图标记的ZIndex
        /// </summary>
        [Category("地图"),Description("地图标记的显示顺序，50-99，数字越大越靠前。")]
        public int ZIndex
        {
            get { return _ZIndex; }
            set 
            {
                if (value >= 50 && value < 100)
                {
                    _ZIndex = value;
                }
                else
                {
                    throw (new ArgumentOutOfRangeException());
                }
            }
        }

        
        /// <summary>
        /// 构造函数
        /// </summary>
        public MapMarker()
        {
        }

        /// <summary>
        /// 重载构造函数
        /// </summary>
        /// <param name="geoCode"></param>
        public MapMarker(string geoCode)
        {
            _GeoCode = geoCode;
        }

        /// <summary>
        /// 重载构造函数
        /// </summary>
        /// <param name="geocode">经纬度坐标</param>
        /// <param name="marker">标记字符</param>
        /// <param name="color">标记颜色</param>
        public MapMarker(string geocode, char marker, MarkerColor color)
        {
            _GeoCode = geocode;
            _Marker = marker;
            _Color = color;
        }
        /// <summary>
        /// 重载构造函数
        /// </summary>
        /// <param name="geocode">经纬度坐标</param>
        /// <param name="size">标记大小</param>
        /// <param name="color">标记颜色</param>
        public MapMarker(string geocode, MarkerSize size, MarkerColor color)
        {
            _GeoCode = geocode;
            _Size = size;
            _Color = color;
        }

        /// <summary>
        /// 重载构造函数
        /// </summary>
        /// <param name="geocode">经纬度坐标</param>
        /// <param name="marker">标记名称</param>
        /// <param name="color">标记颜色</param>
        /// <param name="tooltipText">提示文本</param>
        public MapMarker(string geocode, char marker, MarkerColor color, string tooltipText)
        {
            _GeoCode = geocode;
            _Marker = marker;
            _Color = color;
            _ToolTipText = tooltipText;
        }

        /// <summary>
        /// 重载构造函数
        /// </summary>
        /// <param name="geocode">经纬度坐标</param>
        /// <param name="marker">标记名称</param>
        /// <param name="color">标记颜色</param>
        /// <param name="tooltipText">提示文本</param>
        public MapMarker(string geocode, char marker, MarkerColor color, UIElement userDrawingElement)
        {
            _GeoCode = geocode;
            _Marker = marker;
            _Color = color;
            _ToolTipText = string.Empty;
            _UserDrawingElement = userDrawingElement;
        }


        /// <summary>
        /// 重载构造函数
        /// </summary>
        /// <param name="geocode">经纬度坐标</param>
        /// <param name="marker">标记名称</param>
        /// <param name="color">标记颜色</param>
        /// <param name="tooltipText">提示文本</param>
        /// <param name="tag">用户数据</param>
        public MapMarker(string geocode, char marker, MarkerColor color, string tooltipText, object tag)
        {
            _GeoCode = geocode;
            _Marker = marker;
            _Color = color;
            _ToolTipText = tooltipText;
            _Tag = tag;
        }

        /// <summary>
        /// 重写toString方法
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            return string.Format("{0},{1}{2}{3}", _GeoCode, _Size.ToString()
                , _Color.ToString(), _Marker).Trim();
        }
    }//end class

    #endregion 

    #region 地图标记大小枚举

    /// <summary>
    /// 标记大小
    /// </summary>
    public enum MarkerSize
    {
        Tiny,
        Mid,
        Small
    }//end enum

    #endregion

    #region 标记颜色枚举

    /// <summary>
    /// 标记颜色
    /// </summary>
    public enum MarkerColor
    {
        Black = 0,
        Brown,
        Green,
        Purple,
        Yellow,
        Blue,
        Gray,
        Orange,
        Red,
        White
    }//end class

    #endregion

    //#region 地图标记需要快捷菜单委托、事件及参数

    ///// <summary>
    ///// 地图标记需要快捷菜单委托
    ///// </summary>
    ///// <param name="sender"></param>
    ///// <param name="e"></param>
    //public delegate void MarkerContextMenuStripNeededEventHandler(object sender 
    //, MarkerContextMenuStripNeededEventArgs e) ;

    ///// <summary>
    ///// 地图标记需要快捷菜单事件参数类
    ///// </summary>
    //public class MarkerContextMenuStripNeededEventArgs : System.EventArgs
    //{
    //    /// <summary>
    //    /// 地图标记
    //    /// </summary>
    //    private MapMarker _MapMarker = null;

    //    /// <summary>
    //    /// 设置或获得地图标记
    //    /// </summary>
    //    public MapMarker Marker
    //    {
    //        get
    //        {
    //            return _MapMarker;
                     
    //        }
    //        set
    //        {
    //            _MapMarker = value;
    //        }
    //    }

        ///// <summary>
        ///// 快捷菜单
        ///// </summary>
        //private ContextMenuStrip _ContextMenuStrip = null;

        ///// <summary>
        ///// 设置或获得快捷菜单
        ///// </summary>
        //public ContextMenuStrip ContextMenu
        //{
        //    get
        //    {
        //        return _ContextMenuStrip;
        //    }
        //    set
        //    {
        //        _ContextMenuStrip = value;
        //    }

        //}

        ///// <summary>
        ///// 构造函数
        ///// </summary>
        //public MarkerContextMenuStripNeededEventArgs()
        //{
        //}

        ///// <summary>
        ///// 构造函数
        ///// </summary>
        ///// <param name="marker">需要快捷菜单的地图标记</param>
        ///// <param name="contextMenu">要显示的快捷菜单</param>
        //public MarkerContextMenuStripNeededEventArgs(MapMarker marker, ContextMenuStrip contextMenu)
        //{
        //    _ContextMenuStrip = contextMenu;
        //    _MapMarker = marker;
        //}

    //}//end method

    //#endregion

}//end namespace
